package com.mytools.common.example.threadPool;

import com.mytools.common.example.threadPool.reject.DiscardOldestPolicy;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;

/**
 * @author LJK
 * @description
 * @date 2025/1/30
 */
public class Main {
    public static void main(String[] args) {

        MyThreadPool myThreadPool = new MyThreadPool(2,7,2, TimeUnit.SECONDS,
                new DiscardOldestPolicy(),
                new ArrayBlockingQueue<>(2));
        for (int i = 0; i < 8; i++) {
            myThreadPool.execute(() -> {
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println(Thread.currentThread().getName());
            });
        }

        System.out.println("主线程进行完毕");
    }
}
